﻿Imports System.Data
Imports System.Data.SqlClient

Public Class TrabajadorCuentaADO
    Dim MiConexion As New ConexionADO
    Dim cnx As New SqlConnection(MiConexion.GetCnxSygnus)
    Dim cmd As New SqlCommand
    Dim lExito As Boolean

    Public Function ListarCentroCostoXTrabajador(ByVal p_Compania As String) As DataTable
        Try
            Dim cn As New SqlConnection(MiConexion.GetCnxSygnus)
            Using cn
                Dim cmd As New SqlCommand("pr_CentroCostos", cn)
                Using cmd
                    cmd.CommandType = Data.CommandType.StoredProcedure
                    cmd.Parameters.Add("@compania", SqlDbType.Char, 3)
                    cmd.Parameters("@compania").Value = p_Compania
                    'cmd.Parameters.Add("@lugartrabajo", SqlDbType.Char, 2)
                    'cmd.Parameters("@lugartrabajo").Value = Nothing
                    'cmd.Parameters.Add("@locacion", SqlDbType.Char, 2)
                    'cmd.Parameters("@locacion").Value = Nothing
                    'cmd.Parameters.Add("@vendor", SqlDbType.Char, 6)
                    'cmd.Parameters("@vendor").Value = Nothing
                    Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
                    Dim dt As DataTable = New DataTable("TraCuenta")
                    da.Fill(dt)
                    Return dt
                End Using
            End Using
        Catch myException As Exception
            MsgBox("TrabajadorCuentaADO (ListarCentroCostoXTrabajador) --> " & myException.Message, MsgBoxStyle.Critical)
            Return Nothing
        End Try
    End Function


    Public Function ListarCentroCostoXTrabajadorResidencia(ByVal p_Compania As String) As DataTable
        Try
            Dim cn As New SqlConnection(MiConexion.GetCnxSygnus)
            Using cn
                Dim cmd As New SqlCommand("pr_CentroCostosResidencia", cn)
                Using cmd
                    cmd.CommandType = Data.CommandType.StoredProcedure
                    cmd.Parameters.Add("@compania", SqlDbType.Char, 3)
                    cmd.Parameters("@compania").Value = p_Compania
                    'cmd.Parameters.Add("@lugartrabajo", SqlDbType.Char, 2)
                    'cmd.Parameters("@lugartrabajo").Value = Nothing
                    'cmd.Parameters.Add("@locacion", SqlDbType.Char, 2)
                    'cmd.Parameters("@locacion").Value = Nothing
                    'cmd.Parameters.Add("@vendor", SqlDbType.Char, 6)
                    'cmd.Parameters("@vendor").Value = Nothing
                    Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
                    Dim dt As DataTable = New DataTable("TraCuenta")
                    da.Fill(dt)
                    Return dt
                End Using
            End Using
        Catch myException As Exception
            MsgBox("TrabajadorCuentaADO (ListarCentroCostoXTrabajadorResidencia) --> " & myException.Message, MsgBoxStyle.Critical)
            Return Nothing
        End Try
    End Function

End Class



